using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisParameterSignature : AnalysisDeclaration
{
    internal AnalysisParameterSignature(
        ParameterSignature syntaxNode,
        AnalysisNode? parent) :
        base(AnalysisBoundKinds.ParameterSignature, syntaxNode, parent)
    {
        Syntax = syntaxNode;
        Binding = AnalysisNodeFactory.TypeBinding(syntaxNode.Binding, this);
    }

    public override ParameterSignature Syntax { get; }

    public AnalysisTypeBinding Binding { get; }

    public override int ChildrenCount => 2;

    public override IEnumerable<AnalysisNode> GetChildren()
    {
        return [NameIdentifier, Binding];
    }
}

public static partial class AnalysisNodeFactory
{
    /// <summary>
    /// 创建一个参数签名
    /// </summary>
    /// <param name="syntaxNode">原始语法节点</param>
    /// <param name="parent">父节点，可以忽略</param>
    public static AnalysisParameterSignature ParameterSignature(
        ParameterSignature syntaxNode,
        AnalysisNode? parent)
    {
        return new AnalysisParameterSignature(syntaxNode, parent);
    }
}